
import Vue from 'vue'//因为路由是插件，插件的使用需要用的Vue.use方法
import Router from 'vue-router'//引入路由插件，Router是一个构造方法
Vue.use(Router);

// import DoubleOneOne from '../pages/jing/DoubleOneOne.vue'
// import HomeCom from '../pages/jing/HomeCom.vue'
import MainHtml from '../pages/yan/MainHtml.vue'
import HonorClass from '../pages/yan/HonorClass.vue'
import SmartScreen from '../pages/yan/SmartScreen.vue'
import Setting from '../pages/yan/Setting.vue'
import HotSell from '../pages/yan/HotSell.vue'
import Vip from '../pages/yan/Vip.vue'

import TelPhone from '../pages/jing/TelPhone.vue'
import HomeCom from '../pages/jing/HomeCom.vue'
import DoubleOne from '../pages/jing/DoubleOne.vue'
import EarPorts from '../pages/jing/EarPorts.vue'
import PhoneDetails from '../pages/jing/PhoneDetails.vue'
import GloryLogin from '../pages/jing/GloryLogin.vue'
import GloryReg from '../pages/jing/GloryReg.vue'

import NewsCenter from '../pages/shen/NewsCenter.vue'
import ActionNews from '../pages/shen/ActionNews.vue'

import SeeMore from '../pages/shen/SeeMore.vue'

import ClassiFy from "../pages/guan/ClassiFy.vue"
import MyDetails from "../pages/guan/MyDetails.vue"
import SureList from '../pages/guan/SureList.vue'
import CashDesk from '../pages/guan/CashDesk.vue'

import FirstPage from '../pages/wang/FirstPage.vue'
import TotalCredits from '../pages/wang/TotalCredits.vue'
import CreditsExchange from '../pages/wang/CreditsExchange.vue'

import OrderCenter from '../pages/wang/OrderCenter.vue'


import FlatBoard from '../pages/shen/FlatBoard.vue'

import ThingDetails from '../pages/shen/ThingDetails.vue'


import GoodsDetaills from '../pages/wang/GoodsDetaills.vue'
import ComputerPage from '../pages/wang/ComputerPage.vue'

//glp
import ListCenter from "../pages/guan/ListCenter.vue"
//

const router = new Router({
    routes: [
        {
            path: '/phone',
            name: '/phone',
            component: () => import('../pages/jing/TelPhone.vue')
        },
        {
            path: '/myhome',
            name: '/myhome',
            component: () => import('../pages/jing/HomeCom.vue')

        },
        {
            path: '/double',
            component: () => import('../pages/jing/DoubleOne.vue')
        },

        {
            path: '/main',
            component: () => import('../pages/yan/MainHtml.vue')
        },

        {

            path: '/ears',
            name: '/ears',
            component: () => import('../pages/jing/EarPorts.vue')

        },
        {
            path: '/newscenter',
            component: () => import('../pages/shen/NewsCenter.vue')
        },
        {
            path: '/actionnews',
            component: () => import('../pages/shen/ActionNews.vue')
        },
        {
            path: '/main',
            component: MainHtml
        },
        {
            path: '/second',
            component: () => import('../pages/yan/HonorClass.vue')

        },
        {

            path: '/classify',
            component: () => import('../pages/guan/ClassiFy.vue')
        },
        {
            path: "/mydetails",
            component: () => import('../pages/guan/MyDetails.vue')
        },
        {
            path: '/seemore',
            component: () => import('../pages/shen/SeeMore.vue')
        },
        {
            path: '/wode',
            component: () => import('../pages/wang/FirstPage.vue')
        },
        {
            path: '/jifen',
            component: () => import('../pages/wang/TotalCredits.vue')
        },
        {
            path: '/duihuan',
            component: () => import('../pages/wang/CreditsExchange.vue')
        },
        {

            path: '/buyphone',
            component: () => import('../pages/jing/PhoneDetails.vue')

        },
        {
            path: '/smartscreen',
            name: '/smartscreen',
            component: SmartScreen
        },
        {

            path: '/buyphone',
            name: '/buyphone',
            component: () => import('../pages/jing/PhoneDetails.vue')


        },
        {
            path: '/',
            redirect: '/myhome'
        },
        {
            path: '/center',
            component: OrderCenter
        },
        {
            path: '/surelist',
            component: SureList
        },
        {
            path: '/cashdesk',
            component: CashDesk
        },
        {
            path: '/setting',
            component: Setting
        },
        {
            path: '/me',
            component: FirstPage
        },
        {
            path: '/hotsell',
            component: HotSell
        },
        {

            path: '/surelist',
            component: SureList
        },
        {
            path: '/cashdesk',
            component: CashDesk

        },
        {
            name: "/login",
            path: "/login",
            component: GloryLogin
        },
        {
            name: "/reg",
            path: "/reg",
            component: GloryReg
        },
        {
            path: '/flatboard',
            component: FlatBoard
        },
        {
            path: '/vip',
            component: Vip

        },
        {
            path: '/computer',
            component: ComputerPage 
        },
        {
            path: '/goods',
            component: GoodsDetaills 
        },
        {

        path: '/phone',
        name: '/phone',
        component:()=>import('../pages/jing/TelPhone.vue') 
    },
    {
        path:'/myhome',
        name:'/myhome',
        component:()=>import('../pages/jing/HomeCom.vue') 

    },
    {
        path: '/double',
        component: () => import('../pages/jing/DoubleOne.vue')
    },

    {
        path: '/main',
        component: () => import('../pages/yan/MainHtml.vue')
    },

    {

        path:'/ears',
        name:'/ears',
        component:()=>import('../pages/jing/EarPorts.vue')

    },
    {
        path: '/newscenter',
        component: () => import('../pages/shen/NewsCenter.vue')
    },
    {
        path: '/actionnews',
        component: () => import('../pages/shen/ActionNews.vue')
    },
    {
        path: '/main',
        component: MainHtml
    },
    {
        path: '/second',
        component: () => import('../pages/yan/HonorClass.vue')

    },
    {

        path: '/classify',
        component: () => import('../pages/guan/ClassiFy.vue')
    },
    {
        path: "/mydetails",
        component: () => import('../pages/guan/MyDetails.vue')
    },
    {
        path: '/seemore',
        component: () => import('../pages/shen/SeeMore.vue')
    },
    {
        path: '/wode',
        component: () => import('../pages/wang/FirstPage.vue')
    },
    {
        path: '/jifen',
        component: () => import('../pages/wang/TotalCredits.vue')
    },
    {
        path: '/duihuan',
        component: () => import('../pages/wang/CreditsExchange.vue')
    },
    {

        path: '/buyphone',
        component: () => import('../pages/jing/PhoneDetails.vue')
        
    },
        {  
        path:'/smartscreen',
        name:'/smartscreen',
        component:SmartScreen
    },
    {
        path:'/buyphone',
        name:'/buyphone',
        component:()=>import('../pages/jing/PhoneDetails.vue')
    },
    {
        path:'/buyears',
        name:'/buyears',
        component:()=>import('../pages/jing/EarsDetails.vue')
    },
    {
        path: '/',
        redirect: '/myhome'
    },
    {
        path: '/center',
        component: OrderCenter
    },
    {
        path: '/surelist',
        component: SureList
    },
    {
        path: '/cashdesk',
        component: CashDesk
    },
    {
        path:'/setting',
        component:Setting
    },
    {
        path:'/me',
        component:FirstPage
    },
    {
        path:'/hotsell',
        component:HotSell
    },
    {

         path:'/surelist',
         component:SureList
    },
    {
         path:'/cashdesk',
         component:CashDesk

        },
        {
            name:"/login",
            path:"/login",
            component:GloryLogin
        },
        {
            name:"/reg",
            path:"/reg",
            component:GloryReg
        },
    {
        path:'/flatboard',
        component:FlatBoard
    },

        //glp
        // {
        //     path:'/denglu',
        //     component:DengLu
        // }
        //
        {
            path: '/phone',
            name: '/phone',
            component: () => import('../pages/jing/TelPhone.vue')
        },
        {
            path: '/myhome',
            name: '/myhome',
            component: () => import('../pages/jing/HomeCom.vue')

        },
        {
            path: '/double',
            component: () => import('../pages/jing/DoubleOne.vue')
        },

        {
            path: '/main',
            component: () => import('../pages/yan/MainHtml.vue')
        },

        {

            path: '/ears',
            name: '/ears',
            component: () => import('../pages/jing/EarPorts.vue')

        },
        {
            path: '/newscenter',
            component: () => import('../pages/shen/NewsCenter.vue')
        },
        {
            path: '/actionnews',
            component: () => import('../pages/shen/ActionNews.vue')
        },
        {
            path: '/main',
            component: MainHtml
        },
        {
            path: '/second',
            component: () => import('../pages/yan/HonorClass.vue')

        },
        {

            path: '/classify',
            component: () => import('../pages/guan/ClassiFy.vue')
        },
        {
            path: "/mydetails",
            component: () => import('../pages/guan/MyDetails.vue')
        },
        {
            path: '/seemore',
            component: () => import('../pages/shen/SeeMore.vue')
        },
        {
            path: '/wode',
            component: () => import('../pages/wang/FirstPage.vue')
        },
        {
            path: '/jifen',
            component: () => import('../pages/wang/TotalCredits.vue')
        },
        {
            path: '/duihuan',
            component: () => import('../pages/wang/CreditsExchange.vue')
        },
        {

            path: '/buyphone',
            component: () => import('../pages/jing/PhoneDetails.vue')

        },
        {
            path: '/smartscreen',
            name: '/smartscreen',
            component: SmartScreen
        },
        {
            path: '/buyphone',
            name: '/buyphone',
            component: () => import('../pages/jing/PhoneDetails.vue')
        },
        {
            path: '/buyears',
            name: '/buyears',
            component: () => import('../pages/jing/EarsDetails.vue')
        },
        {
            path: '/',
            redirect: '/myhome'
        },
        {
            path: '/center',
            component: OrderCenter
        },
        {
            path: '/surelist',
            component: SureList
        },
        {
            path: '/cashdesk',
            component: CashDesk
        },
        {
            path: '/setting',
            component: Setting
        },
        {
            path: '/me',
            component: FirstPage
        },
        {
            path: '/hotsell',
            component: HotSell
        },
        {

            path: '/surelist',
            component: SureList
        },
        {
            path: '/cashdesk',
            component: CashDesk

        },
        {
            name: "/login",
            path: "/login",
            component: GloryLogin
        },
        {
            name: "/reg",
            path: "/reg",
            component: GloryReg
        },
        {
            path: '/flatboard',
            component: FlatBoard
        },

        {
            path: '/thingdetails',
            component: ThingDetails
        },


        //glp
        {
            path: '/listcerter',
            component: ListCenter
        },
        {
            name:"/cart",
            path:"/cart",
            component:()=>import('../pages/jing/GloryCart'),
            children:[
                {
                    name:"shopcart",
                    path:'shopcart',
                    component:()=>import('../components/jing/GloryCart/HaveCart'),
                }
            ]
        },
        {
            path:"shopcart",
            component:()=>import('../components/jing/GloryCart/HaveCart')
        }
    ]
})
router.beforeEach((to, from, next) => {
    console.log(to);
    console.log(from)
    let token = localStorage.getItem("token");
    if (to.path == '/wode' || to.path == '/cart') {
        if (token) {
            next()
        }else{
            Vue.prototype.$toast("请先登录")
            setTimeout(() => {
                next('/login')
            }, 1000)
        }
    }
    next()
})
export default router;